<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改辅料异常记录')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-exception-edit" th:object="${partIngredientsException}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">异常辅料：</label>
                <div class="col-sm-8" th:object="${ingredients}">
                    <select name="partId" id="partId" class="form-control" data-none-selected-text="请选择" onchange="getSub(this.value)">
                        <option value="">请选择</option>
                        <option th:each="ing : ${ingredients}" th:text="${ing.name}" th:value="${ing.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">子名字：</label>
                <div class="col-sm-8">
                    <input name="sunName" disabled th:field="*{sunName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">异常数量：</label>
                <div class="col-sm-8">
                    <input name="changeValue" th:field="*{changeValue}" class="form-control" type="number">
                </div>
            </div>
            <div class="form-group" th:object="${users}">
                <label class="col-sm-3 control-label">发现者：</label>
                <div class="col-sm-8">
                    <select name="discoverer" id="discoverer" class="form-control" data-none-selected-text="请选择">
                        <option value="">请选择</option>
                        <option th:each="user : ${users}" th:text="${user.userName}"
                                th:value="${user.userName}" ></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">发现时间：</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control time-input" id="startTime" placeholder="发现时间"
                           name="findDate" th:field="*{findDate}" data-format="yyyy-MM-dd HH:mm:ss"/>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark"  th:field="*{remark}" maxlength="500" class="form-control" rows="3"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "system/exception";
        $("#form-exception-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-exception-edit').serialize());
            }
        }
        $(function() {
            var e = [[${partIngredientsException}]];
            $("#partId option[value= " + e.partId + "]").prop("selected",true);
            $("#discoverer option[value= " + e.discoverer + "]").prop("selected",true);
            $("#startTime").val(e.findDate);
        });
        function getSub(value) {
            var arrays = [[${ingredients}]];
            for (var i = 0; i < arrays.length; i++) {
                if(value == arrays[i].id){
                    $("#subName").val(arrays[i].subName);
                }
            }
        }
    </script>
</body>
</html>